#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N = 15;
char arr[N][N];
bool mp[N][N];
int n, m;
int main()
{
    while ((scanf("%d%d", &n, &m)) != EOF) {
        memset(arr, 0, sizeof(arr));
        memset(mp, 0, sizeof(mp));
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                cin >> arr[i][j];
                if (arr[i][j] == '1') {
                    mp[i][j] = 1;
                }
            }
        }
        int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
        bool flag1 = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (arr[i][j] == '1') {
                    x1 = i;
                    y1 = j;
                    flag1 = 0;
                    break;
                }
            }
            if (flag1 == 0) {
                break;
            }
        }
        flag1 = 1;
        for (int i = n; i >= 1; i--) {
            for (int j = m; j >= 1; j--) {
                if (arr[i][j] == '1') {
                    x2 = i;
                    y2 = j;
                    flag1 = 0;
                    break;
                }
            }
            if (flag1 == 0) {
                break;
            }
        }
        bool flag = 1;
        for (int i = x1; i <= x2; i++) {
            for (int j = y1; j <= y2; j++) {
                if (arr[i][j] != '1') {
                    flag = 0;
                    break;
                }
            }
            if (flag == 0) {
                break;
            }
        }
        bool flag3 = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                if (mp[i][j] == 1) {
                    if (i<x1 || i>x2 || j<y1 || j>y2) {
                        flag3 = 0;
                    }
                }
            }
            if (flag3 == 0) {
                break;
            }
        }
        if (flag && flag3) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}